package cn.ronghuanet.user.rabbitmq.listener;

import cn.ronghuanet.base.util.SmsUtil;
import cn.ronghuanet.user.dto.SendEmailDTO;
import cn.ronghuanet.user.dto.SendSmsDTO;
import cn.ronghuanet.user.rabbitmq.config.RegisterNoticeRabbitmqConfig;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class RegisterNoticeRabbitmqListener {

    /**
     * 标明当前方法需要监听哪一个队列
     */
    @RabbitListener(queues = RegisterNoticeRabbitmqConfig.QUEUE_INFORM_SMS)
    public void listenerSendSms(SendSmsDTO dto){
        // 调用发送短信的接口,发送短信给别人
        //SmsUtil.sendSms(dto.getRecipient(),dto.getContent());
        // 能够打印出来,就说明消息消费成功了
        System.out.println(dto);
    }

    @RabbitListener(queues = RegisterNoticeRabbitmqConfig.QUEUE_INFORM_EMAIL)
    public void listenerSendEmail(SendEmailDTO dto){
        // 拿到消息体的内容后,调用邮件发送接口将邮件发送出去  @TODO
        System.out.println(dto);
    }
}
